home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 18
/
018.d81
/
com64 grapher
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
7KB
|
240 lines
10 dimg(60),c(60):z=0:x=0
11 df=0: rem is data present?
15 poke53280,6:poke53281,3:printchr$(147):poke646,0
20 co=7:ro=4:gosub790:print"*** com 64 grapher menu ***"
25 print:print:printtab(11)chr$(18)"s"chr$(146)"tart new graph file"
30 print:printtab(11)chr$(18)"r"chr$(146)"ead file from disc"
35 print:printtab(11)chr$(18)"w"chr$(146)"rite file to disk"
40 print:printtab(11)chr$(18)"a"chr$(146)"dd to existing data"
45 print:printtab(11)chr$(18)"c"chr$(146)"hange prior entry"
50 print:printtab(11)chr$(18)"f"chr$(146)"ormat change"
55 print:printtab(11)chr$(18)"l"chr$(146)"ist current data"
60 print:printtab(11)chr$(18)"g"chr$(146)"raph data"
62 print:printtab(11)chr$(18)"q"chr$(146)"uit"
65 geta$:ifa$=""then65
66 ifa$="q"then63000
70 ifa$="s"thenz=o:cc=1:goto115
75 ifa$="r"thengosub520:goto15
80 ifa$="a"thenifdf<>0then printchr$(147):n=e:cc=c(n-1)+1:goto176
82 ifa$="a"thengosub60000:goto15
85 ifa$="w"thengosub445:goto15
90 ifa$="l"thengosub615:zz=e-1:goto15
95 ifa$="c"thenifdf<>0then705
96 ifa$="c"thengosub60000:goto15
100 ifa$="g"then245
105 ifa$="f"thengosub755:goto15
110 goto15
115 ifx>0then65
117 df=1
120 printchr$(147):co=2:ro=1:gosub790
122 print"name of graph: ";:gosub950:t$=b$
125 print:printtab(2)"minimum value for bottom axis: ";:u=1:gosub950:b=val(b$)
130 print:printtab(2)"value of vertical interval: ";:u=1:gosub950
132 s=val(b$)
135 print:printtab(2)"name of bottom axis: ";:gosub950:x$=b$
140 print:printtab(2)chr$(156)"all bars the same color - press 'a'"
145 print:printtab(2)"different colored bars - press 'b'"
150 get a$:ifa$=""then150
155 ifa$="a"thenz=1:forv=1to60:c(v)=2:next:goto170
160 ifa$="b"then170
165 goto150
170 n=1:print:printtab(2)chr$(30)"input up to 60 values"
175 print:printtab(2)"type '-1' to end input"
176 co=2:ro=17:gosub790
177 ifdf=0thengosub60000:goto15
178 printchr$(28)"range of graph is"b"to"b+5*s;chr$(144)
180 co=2:ro=20:gosub790
182 print"value to be graphed,bar #";n;" ";
185 co=32:ro=20:gosub790:u=1:gosub950:g(n)=val(b$)
190 gn=g(n)
192 ifgn<>-1andgn<borgn>b+5*sthenco=2:r0=20:gosub790:gosub780:goto180
195 ifgn=-1thenw=0:e=n:goto15
200 ifz=1thenc(n)=2
205 ifz=1andn=60thenw=0:goto15
210 ifgn<borgn>b+5*sthen180
215 ifz=1thenn=n+1:goto180
220 ifcc=11thencc=1
225 c(n)=cc
230 cc=cc+1
235 ifn=60then15
240 n=n+1:goto180
245 ifdf=0thengosub60000:goto15
246 fl=0:forck=0toe:ifg(ck)>b+5*sthenfl=1
247 nextck
248 iffl=1thengosub61000
249 w=0:poke53280,0:poke53281,0:poke646,5
250 printchr$(147)tab(8+(32-int(len(t$)))/2)t$
255 forp=1to20:co=1:ro=p:gosub790
260 printtab(7)"[180] [167]":next
265 co=1:ro=21:gosub790:printb;tab(7)"[204][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][186]"
270 forp=1to4:co=1:ro=21-4*p:gosub790
275 printb+p*s;tab(7)"[204][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][186]"
280 next
285 co=1:ro=1:gosub790
290 printb+5*s;tab(7)"[175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175]"
295 ifw<>0then305
300 x=1
305 ifg(x)=-1thenc(x)=2:goto355
310 y=int(4*(g(x)-b)/s)
315 ls=1871:lc=56143
316 forr=0to(y-1)
317 l1=ls+2*(x-15*w)-40*r
318 l2=lc+2*(x-15*w)-40*r
319 ifl1<1064thenr=y-1:goto325
320 pokel1,160:pokel2,c(x)
325 nextr
330 ifx=15then355
335 ifx=30then355
340 ifx=45then355
345 ifx=60then355
350 x=x+1:goto305
355 co=(40-len(x$))/2:ro=23:gosub790:printx$;
360 ifw<>0thengosub415:goto375
365 co=9:row=22:gosub790:print"1 2 3 4 5 6 7 8 9 1 1 1 1 1 1";
370 co=27:ro=23:gosub790:print"0 1 2 3 4 5";:printchr$(158);
375 co=0:ro=24:gosub790:print"press:'p' to print - any key to go on";
380 get a$:if a$=""then380
385 ifa$="p"thengosub815
390 ifx=15andx<e-1thenw=1:x=x+1:poke646,5:goto250
395 ifx=30andx<e-1thenw=2:x=x+1:poke646,5:goto250
400 ifx=45andx<e-1thenw=3:x=x+1:poke646,5:goto250
405 ifx=15orx=30orx=45andx=e-1then15
410 goto15
415 ifw=1thenco=9:ro=22:gosub790:print"1 1 1 1 2 2 2 2 2 2 2 2 2 2 3"
420 ifw=1thenprinttab(9)"6 7 8 9 0 1 2 3 4 5 6 7 8 9 0";
422 ifw=1thenprintchr$(158);:return
425 ifw=2thenco=9:ro=22:gosub790:print"3 3 3 3 3 3 3 3 3 4 4 4 4 4 4"
430 ifw=2thenprinttab(9)"1 2 3 4 5 6 7 8 9 0 1 2 3 4 5";
432 ifw=2thenprintchr$(158);:return
435 ifw=3thenco=9:ro=22:gosub790:print"4 4 4 4 5 5 5 5 5 5 5 5 5 5 6"
440 ifw=3thenprinttab(9)"6 7 8 9 0 1 2 3 4 5 6 7 8 9 0";
442 ifw=3thenprintchr$(158);:return
445 rem-write to disc
447 ifdf=0thengosub60000:return
450 printchr$(147);"the graph being recorded is titled":print:printt$
455 open2,8,2,"@0:"+t$+",s,w"
460 print#2,z
465 print#2,b
470 print#2,s
475 print#2,t$
480 print#2,x$
485 print#2,e
490 fori=1toe
495 print#2,g(i)
500 print#2,c(i)
505 next
510 close2
515 return
520 rem-read from tape
525 printchr$(147)
530 input"graph title";t$
535 open2,8,2,"0:"+t$+",s,r"
540 open15,8,15:input#15,e,er$,b1,c:ife<20then555
545 print"file not found. try again!":fort=1to2000:next:close2:close15
550 goto530
555 input#2,z
560 input#2,b
565 input#2,s
570 input#2,t$
575 input#2,x$
580 input#2,e
585 fori=1toe
590 input#2,g(i)
595 input#2,c(i)
600 next
605 close2:close15
610 return
615 h=0:rem-list current data
617 ifdf=0thengosub60000:return
620 printchr$(147):printtab(20-int(len(t$)/2))t$
625 ifh=1thenh=0:next
630 tt=0:ll=99999999:hh=.000000001
635 fori=1toe-1:tt=tt+g(i):ifg(i)<llthenll=g(i)
640 ifg(i)>hhthenhh=g(i)
645 printtab(2)x$;i;tab(30-len(str$(int(g(i)))))g(i)
650 ifi=15ori=30ori=45thenh=1:ff=0:goto680
655 next
660 print:print"end of file"
665 print:print"high value was "hh
670 print"low value was "ll
675 print"average value= ";int((100*tt/(e-1))+.5)/100:ff=1
680 co=12:ro=24:gosub790:print"press any key";
685 geta$:ifa$=""then685
690 ifff=1then15
695 ifi=zandi=15ori=zandi=30ori=zandi=45thenco=0:ro=16:gosub790:goto660
700 goto620
705 rem-change prior entry
710 printchr$(147):print
715 printtab(2)"which entry #: ";:u=1:gosub950:d=val(b$)
720 print:printtab(2)"entry # ";d;" is now"g(d)
725 print:printtab(2)"enter new value: ";:u=1:gosub950:g(d)=val(b$)
730 print:printtab(2)"entry #"d"is now"g(d)
735 print:printtab(2)"color is now key #"c(d)
740 print:printtab(2)"enter new color key #: ";:u=1:gosub950:c(d)=val(b$)
745 fort=1to1000:next
750 goto15
755 rem format change
760 printchr$(147):co=2:ro=6:gosub790
762 printtab(2)"value of bottom axis is ";b
765 print:printtab(2)"enter new value: ";:u=1:gosub950:b=val(b$)
770 print:printtab(2)"value of vertical interval is ";s
775 print:printtab(2)"enter new value: ";:u=1:gosub950:s=val(b$):return
780 print" "
785 co=2:ro=20:gosub790:print"bad entry":fort=1to1000:next:return
790 rem cursor positioning sub-routine
795 printchr$(19)
800 ifro<>0thenpoke214,ro-1:print
805 poke211,co
810 return
815 rem screen copy
820 si$=chr$(15):bs$=chr$(8):po$=chr$(16)
825 rv$=chr$(18):ro$=chr$(146):qt$=chr$(34)
830 mf$=chr$(145):vr=peek(648)*256
835 open4,4:print#4
840 forcl=0to23:qf=0:as$=mf$:forro=0to39
845 sc=peek(vr+40*cl+ro)
850 ifsc=34thenqf=1-qf
855 ifsc<>162then870
860 qf=1-qf:ifqf=1thenas$=as$+rv$+qt$:goto900
865 as$=as$+qt$+ro$:goto900
870 ifqf=1and(sc>=128)thensc=sc-128:goto880
875 ifsc>128thensc=sc-128:rf=1:as$=as$+rv$
880 ifsc<32orsc>95thenas=sc+64:goto895
885 ifsc>31andsc<64thenas=sc:goto895
890 ifsc>63andsc<96thenas=sc+32:goto895
895 as$=as$+chr$(as)
900 ifrf=1thenas$=as$+ro$:rf=0
905 nextro
910 ifqf=0thenprint#4,si$po$"20"as$bs$:goto920
915 print#4,si$+po$+"20"+as$+qt$bs$
920 nextcl:print#4,si$:close4:return
950 rem input subroutine
955 cb=0:q=18:b$="":a$=""
960 geta$:ifa$=chr$(13)then975
965 q=164-q
970 printchr$(q)chr$(32)chr$(146)chr$(157);
975 ifb$=""anda$=chr$(13)then960:rem prevents entering null
980 ifb$=""anda$=chr$(20)then960:rem no delete if no letters are present
985 ifa$=chr$(17)ora$=chr$(29)ora$=chr$(145)ora$=chr$(157)then960
990 ifa$=":"ora$=","ora$>chr$(127)ora$=chr$(19)then960
995 ifa$=chr$(13)thenprintchr$(32):u=0:return
1000 ifu=1then1024
1005 printa$;:b$=b$+a$
1010 l=len(b$)
1015 ifa$=chr$(20)thenb$=le